import {useEffect, useRef} from "react";
import * as echarts from "echarts";

const BarChart = ({ title }) => {
    const chartRef = useRef()
    useEffect(() => {
        const myChart = echarts.init(chartRef.current)
        const option = {
            title: {
                text: title
            },
            xAxis: {
                type: 'category',
                data: ['aa', 'bb', 'cc']
            },
            yAxis: {
                type: 'value'
            },
            series: [
                {
                    data: [11, 22, 33],
                    type: 'bar'
                }
            ]
        }

        option && myChart.setOption(option)
    }, [title])
    return (
        <div ref={chartRef} style={{width: '500px', height: '500px'}}></div>
    )
}

export default BarChart